package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BFastmath;
import com.ruoyi.base.service.IBFastmathService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 速算Controller
 *
 * @author ruoyi
 * @date 2024-04-07
 */
@RestController
@RequestMapping("/base/fastmath")
public class BFastmathController extends BaseController
{
    @Autowired
    private IBFastmathService bFastmathService;

    /**
     * 查询速算列表
     */
    @PreAuthorize("@ss.hasPermi('base:fastmath:list')")
    @GetMapping("/list")
    public TableDataInfo list(BFastmath bFastmath)
    {
        startPage();
        List<BFastmath> list = bFastmathService.selectBFastmathList(bFastmath);
        return getDataTable(list);
    }

    /**
     * 导出速算列表
     */
    @PreAuthorize("@ss.hasPermi('base:fastmath:export')")
    @Log(title = "速算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BFastmath bFastmath)
    {
        List<BFastmath> list = bFastmathService.selectBFastmathList(bFastmath);
        ExcelUtil<BFastmath> util = new ExcelUtil<BFastmath>(BFastmath.class);
        util.exportExcel(response, list, "速算数据");
    }

    /**
     * 获取速算详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:fastmath:query')")
    @GetMapping(value = "/{fastmathId}")
    public AjaxResult getInfo(@PathVariable("fastmathId") Long fastmathId)
    {
        return success(bFastmathService.selectBFastmathByFastmathId(fastmathId));
    }

    /**
     * 新增速算
     */
    @PreAuthorize("@ss.hasPermi('base:fastmath:add')")
    @Log(title = "速算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BFastmath bFastmath)
    {
        return toAjax(bFastmathService.insertBFastmath(bFastmath));
    }

    /**
     * 修改速算
     */
    @PreAuthorize("@ss.hasPermi('base:fastmath:edit')")
    @Log(title = "速算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BFastmath bFastmath)
    {
        return toAjax(bFastmathService.updateBFastmath(bFastmath));
    }

    /**
     * 删除速算
     */
    @PreAuthorize("@ss.hasPermi('base:fastmath:remove')")
    @Log(title = "速算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fastmathIds}")
    public AjaxResult remove(@PathVariable Long[] fastmathIds)
    {
        return toAjax(bFastmathService.deleteBFastmathByFastmathIds(fastmathIds));
    }
}
